﻿/********************************************************
 * 类名： UnitBLL.cs
 * 功能： 计量单位业务层
 *   ver	变更日		作者			变更内容
 * ────────────────────────────────────────
 *   V01.0	2013-11-27	李波			初版
 *
 * Copyright (c) 2013，李波版权所有
 ********************************************************/
using System;
using System.Collections;
using PSS.DAL.SetManage.AuxiliaryInfo;
using PSS.Entity;
using PSS.Entity.SetManage.AuxiliaryInfo;
using PSS.Utility;

namespace PSS.BLL.SetManage.AuxiliaryInfo
{
    public class UnitBLL
    {
        private readonly UnitDAL _dal=new UnitDAL();
        public string GetUnitList(Pagination qcmodel)
        {
            var total = _dal.GetTotal();
            var list = _dal.GetUnitList(qcmodel);
            return JsonHelper.Encode(total, list);
        }
        public string GetUnitListByCombobox()
        {
            return JsonHelper.Encode(_dal.GetUnitListByCombobox());
        }
        public bool ModifyUnit(string data)
        {
            var model = new UnitEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.UnitId = new Guid(row["UnitId"].ToString());
                model.UnitName = row["UnitName"].ToString();
            }
            return _dal.ModifyUnit(model);
        }
        public bool AddUnit(string data)
        {
            var model = new UnitEntity();
            var rows = (ArrayList)JsonHelper.Decode(data);
            foreach (Hashtable row in rows)
            {
                model.UnitId = Guid.NewGuid();
                model.UnitName = row["UnitName"].ToString();
            }
            return _dal.AddUnit(model);
        }
        public string GetUnitInfo(string id)
        {
            return JsonHelper.Encode(_dal.GetUnitInfo(id));
        }
        public bool RemoveUnit(string id)
        {
            return _dal.RemoveUnit(id);
        }
    }
}
